package com.jyxd.web.service.czform;

import com.jyxd.web.dao.czform.CRRTAssessDao;
import com.jyxd.web.dao.czform.CRRTCureDao;
import com.jyxd.web.dao.czform.CRRTNurseDao;
import com.jyxd.web.data.czform.CRRTAssess;
import com.jyxd.web.data.czform.CRRTNurse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class CRRTAssessService {

    @Autowired
    private CRRTAssessDao crrtAssessDao;
    @Autowired
    private CRRTCureDao crrtCureDao;
    @Autowired
    private CRRTNurseDao crrtNurseDao;


    public boolean insert (CRRTAssess crrtAssess) {
        crrtAssess.setStatus(1);
        boolean flag = crrtAssessDao.insert(crrtAssess);
        return flag;
    }

    public boolean update (CRRTAssess crrtAssess) {
        return crrtAssessDao.update(crrtAssess);
    }

    public CRRTAssess queryData (String id) {
        CRRTAssess crrtAssess = crrtAssessDao.queryData(id);
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("crrtAssessId",id);
        List<CRRTNurse> crrtNurses = crrtNurseDao.queryList(map);
        crrtAssess.setCrrtNurseList(crrtNurses);
        return crrtAssess;
    }

    public List<CRRTAssess> queryList (Map<String, Object> map) {
        List<CRRTAssess> crrtAssessList = crrtAssessDao.queryList(map);
//        if (crrtAssessList.size()>0){
//            for (int i=0;i<crrtAssessList.size();i++){
//                CRRTAssess crrtAssess = crrtAssessList.get(i);
//                Map<String,Object> selectMap = new HashMap<String,Object>();
//                selectMap.put("crrtAssessId",crrtAssess.getId());
//                List<CRRTNurse> crrtNurses = crrtNurseDao.queryList(map);
//                crrtAssess.setCrrtNurseList(crrtNurses);
//            }
//        }
        return crrtAssessList;
    }

    public int queryNum (Map<String, Object> map) {
        return crrtAssessDao.queryNum(map);
    }

    public CRRTAssess queryLastData(Map<String, Object> map) {
        CRRTAssess crrtAssess = crrtAssessDao.queryLastData(map);
        return crrtAssess;
    }
}
